package tcpx

import (
	"bufio"
	"fmt"
	"io"
	"net"
	"net/smtp"
	"strconv"
	"sync/atomic"

	"std/netx"
)

type TcpTempX struct {
}

func (t TcpTempX) TcpClient(ii int) {
	conn, err := smtp.Dial(net.JoinHostPort(netx.Ip.String(), strconv.Itoa(netx.Port)))
	if err != nil {
		fmt.Println("err :", err)
		return
	}
	conn.Mail("")

}
func (t TcpTempX) TcpServer() {

}
func (t TcpTempX) process(conn net.Conn) {
	defer conn.Close()
	reader := bufio.NewReader(conn)
	var buf [128]byte
	data := atomic.Int32{}

	for {
		n, err := reader.Read(buf[:])
		if err == io.EOF {
			break
		}
		if err != nil {
			fmt.Println("read from client failed, err:", err)
			break
		}
		recvStr := string(buf[:n])
		fmt.Println("recv data:", data.Load(), recvStr)
		data.Add(1)
	}
}
